﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Fadd.Logging.Targets;
using Fadd.IO.Logging.Targets.File;
using Fadd.Logging;
using System.Threading;
using System.Diagnostics;
using Xunit;

namespace Fadd.Test.Logging.Targets
{
    class FileTargetTest : IFileWriter
    {
        FileTarget _target ;

        public FileTargetTest()
        {
            _target = new FileTarget(this);
        }

        [Fact]
        public void TestEntry()
        {
            _target.Enqueue(new Fadd.Logging.LogEntry
            {
                CreatedAt = DateTime.Now,
                LogLevel = LogLevel.Warning,
                Message = "Hello world",
                ThreadId = Thread.CurrentThread.ManagedThreadId,
                UserName = Environment.UserName,
                StackFrames = new StackTrace(2).GetFrames()
            });
        }

        public FileConfiguration Configuration
        {
            get
            {
                return new FileConfiguration
                {
                    CreateDateFolder = true,
                    Path = @"C:\Temp\",
                    DaysToKeep = 1
                };
            }
        }

        public string Name
        {
            get { return "TestLog"; }
        }

        public void Write(string logEntry)
        {
            throw new NotImplementedException();
        }
    }
}
